package com.testdemo.web.shapecalc.impl;

 

public class HeartQuestionImpl extends ShapeQuestionImpl {
	int Length;
	int Height;
	TriangleQuestionImpl DownTriangle;
	CircleQuestionImpl UpCircle;
	public HeartQuestionImpl(){
		Length = Math.abs((int)(Math.random() * 10 * 2 + 2));
		Height = Math.abs((int)(Math.random() * 10 + 3));
		DownTriangle = new TriangleQuestionImpl(Length, Height);
		UpCircle = new CircleQuestionImpl(Length / 2);			
	}
	public HeartQuestionImpl(TriangleQuestionImpl tri, CircleQuestionImpl c)
	{
		DownTriangle = tri;
		UpCircle = c;		
		Length = tri.Length;
		Height = tri.Height;
	}
	
	public void CalcArea(){
		Area = DownTriangle.getRightArea() + UpCircle.getRightArea();
	}
	public void CalcPerimeter(){
		Perimeter = DownTriangle.getRightPerimeter() + UpCircle.getRightPerimeter() - Length;
	}
	@Override
	public String getQusitionString() {
		// TODO Auto-generated method stub
		String temp;
		temp = "题目：一个为心形，上低边长为 " + Integer.toString(Length) + ", 高为" + 
				Integer.toString(Height) + "请计算该三角形的面积和周长。";
		return temp;
	}
}
